#ifndef DRAGHANDLER_H
#define DRAGHANDLER_H

#include <btRigidBody.h>
#include <btDiscreteDynamicsWorld.h>
#include <btPointConstraint.h>
#include <btHingeConstraint.h>
#include <btConeTwistConstraint.h>
#include <btSixdofConstraint.h>
#include <btSliderConstraint.h>
#include <btSixdofSpringConstraint.h>
#include <btUniversalConstraint.h>
#include <btHinge2Constraint.h>
#include <btGearConstraint.h>
#include <btFixedConstraint.h>
#include <btSequentialConstraintSolver.h>
#include <btRaycastVehicle.h>

#include <BViewer>
#include <BBillboard>
#include <BLine>
#include <BQuad>
#include <BSphere>
#include <BPicker>
#include <BSphereHandler>

using namespace BWE;

class DragHandler : public BSphereHandler
{
public:
	DragHandler();
	~DragHandler();

	void freshDragRing(BReal axisSize);

protected:
	void removePickingConstraint();

protected:
	virtual void render(BRender& render);

	virtual void attachEvent(const BEvent& event);
	virtual void detachEvent(const BEvent& event);

	virtual bool mousePressEvent(const BMouseEvent& mouseEvent);
	virtual bool mouseReleaseEvent(const BMouseEvent& mouseEvent);
	virtual bool mouseMoveEvent(const BMouseEvent& mouseEvent);

protected:
	BVectorArray			_dragRingPoints;
	BLine					_dragLine;
	bool					_spaceShown;
	bool					_leftPressed;
	BLine					_linePressed;
	int						_transStep;
	BVector					_debugPoint;
	BLine					_debugLine;

	BNode*					_pickedNode;
	BVector					_pickedPoint;
	btPointConstraint*		_pickedConstraint;
	btBodyState				_savedState;
	btVector3				_hitPos;
	BReal				_oldPickingDist;

};

#endif